---
title: Deploy Kustomizations
sidebar_label: Kustomizations
---

import FragmentKubectlApplyArgs from '../../../_partials/kubectl-options-applyArgs.mdx';
import FragmentKubectlBinaryPath from '../../../_partials/kubectl-options-binaryPath.mdx';
import FragmentKubectlKustomize from '../../../_partials/kubectl-kustomize.mdx';
import FragmentKustomizeKustomizeArgs from '../../../_partials/kustomize-options-kustomizeArgs.mdx';
import FragmentUpdateImageTags from '../../../_partials/kubectl-updateImageTags.mdx';

To deploy Kustomizations using `kustomize` / `kubectl apply -k`, you need to configure them within the `deployments` section of the `devspace.yaml`.

## Example
```yaml {4} title=devspace.yaml
deployments:
  my-deployment:
    kubectl:
      kustomize: true
      manifests:
      - my-kustomization/
      - another-kustomization/
```

The above example will be executing during the deployment process as follows if the `kustomize` binary is not installed:
```bash
kubectl apply -k my-kustomization/
kubectl apply -k another-kustomization/
```

:::caution Kustomize Deployments
DevSpace only uses `kustomize build` to render the manifest templates. The actual deployment will be executed using `kubectl apply`.
:::


## `kustomize` vs `kubectl -k`
Kustomization deployments require `kubectl` or `kustomize` to be installed. If both are available, DevSpace will use the `kustomize` binary by default.

DevSpace also provides the `kustomizeBinaryPath` field which expects a path to the `kustomize` binary. By default, DevSpace will use the `kustomize` located on your `$PATH`. Use this to specify a location for `kustomize` if it is not on your `$PATH`.

#### Example: Setting Path To Kustomize Binary
```yaml
deployments:
  backend:
    kubectl:
      kustomize: true
      kustomizeBinaryPath: /path/to/kustomize
      manifests:
      - backend/
```
Deploying the above example would use the `/path/to/kustomize` binary to render the manifests.


:::warning
Setting `kustomizeBinaryPath` makes it much harder to share your `devspace.yaml` with other team mates. It is recommended to add `kustomize` to your `$PATH` environment variable instead.
:::



## Update Image Tags

<FragmentUpdateImageTags/>


## Extra Arguments
When deploying manifests via `kubectl`, DevSpace can pass additional arguments and flags to the `kubectl` commands used for the deployment process.

### Args For `kubectl create`
The `createArgs` option expects an array of strings stating additional arguments (and flags) that should be used when calling `kubectl create`.

#### Example: Custom Kubectl Args & Flags
```yaml
deployments:
  backend:
    kubectl:
      manifests:
      - backend/
      createArgs:
      - "--recursive"
```
**Explanation:**  
Deploying the above example would roughly be equivalent to this command:
```bash
kubectl create --dry-run --output yaml --validate=false --recursive -f backend/
```

:::info Kustomize Deployments
DevSpace only uses `kustomize create` to render the manifests using the default flags `--dry-run --output yaml --validate=false`. The actual deployment will be executed using `kubectl apply` after DevSpace has replaced the image tags within the rendered manifests in memory.
:::


### Args For `kubectl apply`

<FragmentKubectlApplyArgs/>


### Args For `kustomize`

<FragmentKustomizeKustomizeArgs/>
